package Person.ith_14;

public class DuoTaiDemo {
    public static void main(String[] args) {
      Animal a =new Dog();
      Animal a2 = new Cat() ;

    }

    public static void method(Dog d){
        d.eat();
    }
    public static void method(Cat c){
        c.eat();
    }
}
/*将共性的功能放在父类中*/
 abstract class Animal{
    public abstract void eat();
}
class Dog extends Animal
{
    @Override
    public void eat()
    {
        System.out.println("骨头");
    }
    public void lookHome()
    {
        System.out.println("看家");
    }
}
class Cat extends Animal{
    @Override
    public void eat()
    {
        System.out.println("鱼");
    }
    public static void method(Dog d){
        d.eat();
    }
}
